import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		// 歌曲列表中歌曲的所有id
		topListIdArr: [],
		// 下一首歌曲的id
		nextId: ''
	},
	mutations: {
		INIT_TOPLISTIDARR(state, topListIdArr) {
			state.topListIdArr = topListIdArr
		},
		NEXT_ID(state,currentId){
			state.topListIdArr.forEach((item,index)=>{
				if(item.id == currentId){
					state.nextId = state.topListIdArr[index+1].id
				}
			})
		}
	}
})
